/*
*    Reversi Contender homepage:  http://code.google.com/p/reversi-contender
*
*    copyright 2011 steven sims <steven.joseph.sims at gmail.com>
*
*    This file is part of Reversi Contender.
*
*    Reversi Contender is free software: you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation, either version 3 of the License, or
*    (at your option) any later version.
*
*    Reversi Contender is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License
*    along with Reversi Contender.  If not, see <http://www.gnu.org/licenses/>.
*/

package org.threadswarm.reversi.gui.animation;

import java.util.EnumMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.jdesktop.core.animation.timing.Animator;
import org.jdesktop.core.animation.timing.AnimatorBuilder;
import org.jdesktop.core.animation.timing.TimingSource;
import org.jdesktop.swing.animation.timing.sources.SwingTimerTimingSource;

/**
 *
 * @author steve
 */
public class AnimatorRepository {
    
    private final static AnimatorRepository INSTANCE = new AnimatorRepository();
    private final Map<AnimationType, Animator> animatorMap = new EnumMap<AnimationType, Animator>(AnimationType.class);
    
    private AnimatorRepository() {
        TimingSource timingSource = new SwingTimerTimingSource();
        timingSource.init();
        Animator availInsertionAnimator = new AnimatorBuilder(timingSource).setRepeatBehavior(Animator.RepeatBehavior.REVERSE)
                .setDuration(700, TimeUnit.MILLISECONDS).setRepeatCount(Animator.INFINITE).setStartDirection(Animator.Direction.BACKWARD).build();
        animatorMap.put(AnimationType.AVAIL_INSERTION, availInsertionAnimator);
    }
    
    public Animator getAnimator(AnimationType animationType) {
        return animatorMap.get(animationType);
    }
    
    public static AnimatorRepository getInstance() {
        return INSTANCE;
    }
}
